package DataStructure.test;

//判断是否有环
public class XunHuanList {

    public static void main(String[] args) throws Exception{
        //创建结点
        Node<Integer> first = new Node<Integer>(1,null);
        Node<Integer> second = new Node<Integer>(2,null);
        Node<Integer> third = new Node<Integer>(3,null);
        Node<Integer> fourth = new Node<Integer>(4,null);
        Node<Integer> fifth = new Node<Integer>(5,null);
        Node<Integer> six = new Node<Integer>(6,null);
        Node<Integer> seven = new Node<Integer>(7,null);
        //完成结点之间的指向
        first.next=second;
        second.next=third;
        third.next=fourth;
        fourth.next=fifth;
        fifth.next=six;
        six.next=seven;
        //构建循环链表
        seven.next=first;
    }


    //节点类
    private static class Node<T>{
        T item;
        Node next;

        public Node(T item,Node next){
            this.item=item;
            this.next=next;
        }
    }
}
